/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.toolbox_basics_project.spring.manager;

import java.util.List;

import com.genia.toolbox.basics.exception.BundledException;
import com.genia.toolbox.persistence.exception.PersistenceException;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.I18nDynamicString;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.I18nDynamicText;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.I18nDynamicValue;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.I18nValue;
import com.genia.toolbox.web.gwt.form.client.value.FormComplexValue;
import com.genia.toolbox.web.gwt.form.server.provider.FormProvider;

/**
 * Common form manager. Used to work with i18n dynamic string or text in forms.
 */
public interface CommonFormManager
{

  /**
   * save an {@link I18nValue}.
   * 
   * @param i18nValue
   *          the value to save
   * @throws PersistenceException
   *           if an error occurred
   */
  public void save(I18nValue i18nValue)
      throws PersistenceException;



  /**
   * save an {@link I18nDynamicValue}.
   * 
   * @param i18nDynamicValue
   *          the value to save
   * @throws PersistenceException
   *           if an error occurred
   */
  public void save(I18nDynamicValue i18nDynamicValue)
      throws PersistenceException;



  /**
   * update an {@link I18nValue}.
   * 
   * @param i18nValue
   *          the value to update
   * @throws PersistenceException
   *           if an error occurred
   */
  public void update(I18nValue i18nValue)
      throws PersistenceException;



  /**
   * update an {@link I18nDynamicValue}.
   * 
   * @param i18nDynamicValue
   *          the value to update
   * @throws PersistenceException
   *           if an error occurred
   */
  public void update(I18nDynamicValue i18nDynamicValue)
      throws PersistenceException;



  /**
   * delete an {@link I18nValue}.
   * 
   * @param i18nValue
   *          the value to delete
   * @throws PersistenceException
   *           if an error occurred
   */
  public void delete(I18nValue i18nValue)
      throws PersistenceException;



  /**
   * delete an {@link I18nDynamicValue}.
   * 
   * @param i18nDynamicValue
   *          the value to delete
   * @throws PersistenceException
   *           if an error occurred
   */
  public void delete(I18nDynamicValue i18nDynamicValue)
      throws PersistenceException;



  /**
   * create a {@link I18nDynamicString} from an i18nTextBoxBase values.
   * 
   * @param i18nTextBoxBaseValues
   *          i18nTextBoxBase values.
   * @return {@link I18nDynamicString}.
   * @throws PersistenceException
   *           when error occurred.
   */
  public abstract I18nDynamicString createI18nDynamicString(List<String> i18nTextBoxBaseValues)
      throws PersistenceException;



  /**
   * create a {@link I18nDynamicText} from an i18nTextBoxBase values.
   * 
   * @param i18nTextBoxBaseValues
   *          i18nTextBoxBase values.
   * @return {@link I18nDynamicText}.
   * @throws PersistenceException
   *           when error occurred.
   */
  public abstract I18nDynamicText createI18nDynamicText(List<String> i18nTextBoxBaseValues)
      throws PersistenceException;



  /**
   * create a list of String from an {@link I18nDynamicValue}.
   * 
   * @param i18nDynamicValue
   *          the {@link I18nDynamicValue}.
   * @return a list of {@link String}.
   */
  public abstract List<String> createStringList(I18nDynamicValue i18nDynamicValue);



  /**
   * update {@link I18nDynamicString} with newValues.
   * 
   * @param i18nDynamicString
   *          {@link I18nDynamicString}.
   * @param newValues
   *          the new values.
   * @throws PersistenceException
   *           when error occurred.
   */
  public abstract void updateI18nDynamicString(I18nDynamicString i18nDynamicString, List<String> newValues)
      throws PersistenceException;



  /**
   * update {@link I18nDynamicText} with newValues.
   * 
   * @param i18nDynamicText
   *          {@link I18nDynamicText}.
   * @param newValues
   *          the new values.
   * @throws PersistenceException
   *           when error occurred.
   */
  public abstract void updateI18nDynamicText(I18nDynamicText i18nDynamicText, List<String> newValues)
      throws PersistenceException;



  /**
   * save a {@link FormComplexValue} using a {@link FormProvider}. This method
   * returns the list of the saved entities.
   * 
   * @param formComplexValue
   *          the {@link FormComplexValue} to save
   * @param formProvider
   *          the {@link FormProvider} to use to save the values
   * @return the list of the identifier of the saved datas.
   * @throws BundledException
   *           if an error occured
   */
  public List<String> saveFormComplexValue(FormComplexValue formComplexValue, FormProvider formProvider)
      throws BundledException;



  /**
   * getter for the languageManager property.
   * 
   * @return the languageManager
   */
  public abstract LanguageManager getLanguageManager();



  /**
   * setter for the languageManager property.
   * 
   * @param languageManager
   *          the languageManager to set
   */
  public abstract void setLanguageManager(LanguageManager languageManager);



  /**
   * create or update an i18nDynamicString.
   * 
   * @param i18nDynamicString
   *          the {@link I18nDynamicString} to create or update.
   * @param newValues
   *          the new values to set.
   * @return the {@link I18nDynamicString}.
   * @throws PersistenceException
   *           when error has occured.
   */
  public I18nDynamicString createOrUpdateI18nDynamicString(I18nDynamicString i18nDynamicString, List<String> newValues)
      throws PersistenceException;



  /**
   * create or update an i18nDynamicText.
   * 
   * @param i18nDynamicText
   *          the {@link I18nDynamicText} to create or update.
   * @param newValues
   *          the new values to set.
   * @return the {@link I18nDynamicText}.
   * @throws PersistenceException
   *           when error has occured.
   */
  public I18nDynamicText createOrUpdateI18nDynamicText(I18nDynamicText i18nDynamicText, List<String> newValues)
      throws PersistenceException;
}